<template>
	<view>
		<view class="address-chose-box" v-if="JSON.stringify(preson)==='{}'">
			<button type="primary" size="mini" @click="btnAddress">请选择收获地址+</button>
		</view>
		
		<view  class="address-main" v-else  @click="btnAddress">
			<view class="top">
				<text class="rou1">收货人：{{preson.userName}}</text>
				<view calss="rou2">
				<text  class="item1">电话：{{preson.telNumber}} </text>
					<uni-icons type="arrowright" size="15"></uni-icons>
				</view>
				
			</view>
			<view  class="bottom">
				<text class="rou1">收货地址：</text>
				<text class="rou2">{{preson.provinceName+preson.cityName+preson.countyName+preson.detailInfo}}</text>
			</view>
		</view>
		<image class="Image" src="../../static/cart_border@2x.png"></image>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				  presons:{}
			
			};
		},
		methods:{
		async btnAddress(){
			 var [err,res]=await uni.chooseAddress()
				console.log(err,res)
			if(err===null&&res.errMsg=="chooseAddress:ok"){			
				this.presons=res
		        
				uni.$Store.commit("address",this.presons)
				uni.setStorageSync("address",this.presons)
			}
			
		  }
		  // async reAuth(){
			 // const [err,res]= await uni.showModal({
			 //  	content:"检测到你没有打开地址权限"
			 //  })
			 //  console.log(res)
			 //  if(res.cancel) return uni.$showMsg("你取消了授权")
			 // if(res.confirm) return uni.openSetting({
				//  success:(settingResult)=>{
				// 	 if(!settingResult.authSetting["scope.address"]) return uni.$showMsg("你取消了授权")
				// 	 if(!settingResult.authSetting["scope.address"]) return uni.$showMsg("授权成功，请选择地址")
				//  }
			 // })
		  // }
		},
		computed:{
			preson(){
				return uni.$Store.state.cartdata.address
			}
		}
	}
</script>

<style lang="scss">
  .address-chose-box{
	  display:flex;
	  height:90px;
	  justify-content: center;
	  align-items:center;
	  .btnAddress{
	
	  }
  }
  .address-main{
	  
	  font-size:12px;
	  padding:0 5px;
	  margin-bottom:8px;
	  .top{
		 
		  display:flex;
		  align-items:center;
		  justify-content:space-between;
		  
	  }
	  .bottom{
		  margin-top:10px;
		  display:flex;
		  		 
		  // justify-content:space-between;
		  align-items: center;
		  .rou1{
			  white-space:nowrap;
		  }
	  }
  }
  .Image{
	  display: block;
	  width:100%;
	  height:5px;
  }
</style>
